package com.sunronsoft.mind.map.model;

import com.jfinal.kit.JsonKit;

import java.io.Serializable;
import java.util.List;

/**
 * @author Sunron
 **/
public class MindMap implements Serializable {
    
    private static final long serialVersionUID = 4499324902877830709L;
    
    public static final int TYPE = 0;   // 分类
    public static final String RIGHT = "right";
    public static final String CENTER = "center";
    
    private Integer id;
    private String topic;
    private String path;
    private Integer type;
    private Integer parentId;
    private String direction;   // left or right
    private boolean expanded;
    private List<MindMap> children;

    public MindMap() {
        this.expanded = false;
        this.direction = RIGHT;
    }
    
    public MindMap(String topic) {
        this(null, topic, null, null);
    }
    
    public MindMap(String topic, String path) {
        this(null, topic, path, null);
    }
    
    public MindMap(String topic, String path, Integer parentId) {
        this(null, topic, path, parentId);
    }
    
    public MindMap(Integer id, String topic, String path, Integer parentId) {
        this.id = id;
        this.topic = topic;
        this.path = path;
        this.parentId = null == parentId ? 0 : parentId;
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public boolean isExpanded() {
        return expanded;
    }

    public void setExpanded(boolean expanded) {
        this.expanded = expanded;
    }

    public List<MindMap> getChildren() {
        return children;
    }

    public void setChildren(List<MindMap> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return JsonKit.toJson(this);
    }
}
